package Classroom.A0408;

public class Demo2 {
    public static void main(String[] args) {

        String s1 = "java";
        String s2 = "java";
        String s3 = new String("java");
        String s4 = new String("java");
        String s5 = "ja" + "va";

        //字符串比较    ==  比较的是地址
        System.out.println(s1 == s2); //true
        System.out.println(s1 == s3); //false
        System.out.println(s3 == s4); //false
        System.out.println(s1 == s5); //true
        System.out.println(s3 == s5); //false

        //比较内容  equals
        System.out.println(s1.equals(s3)); //true

        //忽略大小写比较     验证码
        System.out.println(s1.equalsIgnoreCase("JAVA"));

        //比较两个字符串大小   默认从前往后    java    hello
        String s6 = "hello";
        int i = s1.compareTo(s6);
        System.out.println("i = "+ i);
    }
}
